import { Request, Response } from 'umi';

const authorInfo = {
	name: '10喵喵',
	face: '//oss.10miaomiao.cn/images/miao.jpg',
}

const list = [{
	"id": 6,
	"title": "【React X Kotlin】用kotlin写react是什么味道",
	"createtime": "2018-12-09T16:16:27.000Z",
	"updatetime": "2018-12-09T16:16:27.000Z",
	"time": "2018-12-10 00:16",
	"author": "10喵喵",
	"pic": "//oss.10miaomiao.cn/images/bg4.png",
	authorInfo,
	"content": `<h4 id="1-">1.创建工程</h4>↵<pre><code class="language-shell">create-react-app my-app --scripts-version react-scripts-kotlin</code></pre>`
}, {
	"id": 5,
	"title": "【java作业】写下学校布置的java入门作业，233333333333",
	"createtime": "2018-11-03T05:12:04.000Z",
	"updatetime": "2018-11-18T07:16:25.000Z",
	"time": "2018-11-03 13:12",
	"author": "10喵喵",
	"pic": "//oss.10miaomiao.cn/images/bg4.png",
	authorInfo,
}, {
	"id": 4,
	"title": "【安卓·瞎折腾系列3】简单粗暴的实现双向绑定2",
	"createtime": "2018-06-09T13:37:38.000Z",
	"updatetime": "2018-06-09T13:37:38.000Z",
	"time": "2018-06-09 21:37",
	"author": "10喵喵",
	"pic": "//oss.10miaomiao.cn/images/bg4.png",
	authorInfo,
}, {
	"id": 3,
	"title": "【安卓·瞎折腾系列2】简单粗暴的实现双向绑定",
	"createtime": "2018-06-02T10:50:16.000Z",
	"updatetime": "2018-06-09T13:27:40.000Z",
	"time": "2018-06-02 18:50",
	"author": "10喵喵",
	"pic": "//oss.10miaomiao.cn/images/bg4.png",
	authorInfo,
}, {
	"id": 2,
	"title": "【安卓·瞎折腾系列1】利用anko优雅的使用RecyclerView",
	"createtime": "2018-02-25T08:35:25.000Z",
	"updatetime": "2018-06-09T13:27:31.000Z",
	"time": "2018-02-25 16:35",
	"author": "10喵喵",
	"pic": "//oss.10miaomiao.cn/images/bg4.png",
	authorInfo,
}, {
	"id": 1,
	"title": "【node.js】使用async/await对mysql简单封装，实现同步查询",
	"createtime": "2018-02-07T14:14:17.000Z",
	"updatetime": "2018-06-08T16:30:12.000Z",
	"time": "2018-02-07 22:14",
	"author": "10喵喵",
	"pic": "//oss.10miaomiao.cn/images/bg4.png",
	authorInfo,
}]

const commentList = [{ "id": 25, "name": "御寒剑影", "email": "13530314180@139.com", "website": "http://3e0n185419.wicp.vip/", "content": "妙啊", "createtime": "2020-04-10T13:10:53.000Z", "updatetime": "2020-04-10T13:10:53.000Z", "avatar": "static/images/miao.jpg", "time": "2020-04-10 21:10" }, { "id": 12, "name": "嘴铭", "email": "1281626580@qq.com", "website": "www.4399.com", "content": "蔡FlyJump劲啊", "createtime": "2018-11-09T15:38:52.000Z", "updatetime": "2018-11-09T15:38:52.000Z", "avatar": "static/images/miao.jpg", "time": "2018-11-09 23:38" }, { "id": 11, "name": "裤子", "email": "632999718@qq.com", "website": "www.baidu.com", "content": "蔡飞跃牛逼", "createtime": "2018-11-07T03:16:13.000Z", "updatetime": "2018-11-07T03:16:13.000Z", "avatar": "static/images/miao.jpg", "time": "2018-11-07 11:16" }]


export default {
	"/miao/article/list": {
    list,
    count: list.length,
    pageIndex: 1,
    pageSize: 10,
    pageCount: 1,
  },
	"/miao/article/:id": (req: Request, res: Response) => {
		const id = req.param("id")
		if (id) {
			const data = list.find(item => parseInt(id) === item.id)
			if (data) {
				res.send(data);
				return
			}
		}
		res.status(404);
		res.send({ status: 404, message: "错误" });
	},
	"/miao/article/:id/comment/list": {
		list: commentList,
    count: commentList.length,
    pageIndex: 1,
    pageSize: 10,
    pageCount: 1,
	}
}